package com.dao.Impl;

import com.dao.SupplieDao;
import com.entity.Supplie;
import com.util.JDBC;
import com.util.TransBean;

import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

/**
 * @author 沐白
 */
public class SupplieDaoImpl implements SupplieDao {
    @Override
    public Supplie findById(int id) {
        List<Map> maps = JDBC.selectMap("select id,supplieName,status from supplie where id=?", id);
        if(maps!=null&&maps.size()>0){
            return (Supplie) TransBean.populate(Supplie.class,maps).get(0);
        }
        return null;
    }

    @Override
    public List<Supplie> findAll() {
        List<Map> mapList = JDBC.selectMap("select id,supplieName,status from supplie where status=1");
        List<Supplie> lis = TransBean.populate(Supplie.class, mapList);
        return lis;
    }
}
